package com.huidao.servlet.buyer;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.huidao.entity.Order;
import com.huidao.service.OrderService;
import com.huidao.service.OrderServiceImp;


public class GetListorderServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

    public GetListorderServlet() {
    }


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int currentpage = 1;
		String curren = request.getParameter("currentpage");
		if(curren!=null){
			currentpage=Integer.parseInt(curren);
		}
		OrderService order = new OrderServiceImp();
		int totalpage=order.total(currentpage);
		if(currentpage>totalpage){
			currentpage=totalpage;
		}
		List<Order> list = order.getListOrder(currentpage);
		request.setAttribute("list", list);
		request.setAttribute("currentpage", currentpage);
		request.setAttribute("totalpage", totalpage);
		request.setAttribute("totalPrice", order.getTotalPrice());
		request.getRequestDispatcher("getListOrder.jsp").forward(request, response);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request, response);
	}

}
